<template>
	<view class="container">
		<com-head textTit="介绍客户消费情况" :typeVal="1" :scrollTop="scrollTop"></com-head>
		<view class="totalMoney">
			<u-search :show-action="true" bg-color="#fff" shape="square" action-text="搜索" @search="searchFun" :animation="true" placeholder="请输入用户名称或手机号进行筛选"></u-search>
			<text>总金额：{{money}}</text>
		</view>
		<template v-if="list.length">
			<view class="list" v-for="(ele,index) in list" :key="index">
				<view class="head">
					<view class="right">
						<view class="">用户名称：<text>{{ele.user.username}}</text></view>
						<view class="">手机号：<text>{{ele.user.phone}}</text></view>
						<view class="">时间：<text>{{ele.pay_time}}</text></view>
					</view>
				</view>
				<view class="bottom">
					金额：<text>{{ele.orders_payable}}元</text>
				</view>
			</view>
			<u-loadmore margin-top="50" margin-bottom="50" :status="status" />
		</template>
		<!-- 没有数据时 -->
		<view class="noDate" v-else>
			<image src="https://willmid-img.oss-cn-shanghai.aliyuncs.com/2021/09/10/2x-8.png" mode=""></image>
			<view>您还没有介绍客户哦~</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				value: '',
				show:false,
				list:[],
				status:'loading',
				total:0,
				page:1,
				scrollTop: 0,
				money: 0
			}
		},
		onPageScroll(e){
			this.scrollTop = e.scrollTop
		},
		async onLoad() {
			this.evaluationList()
		},
		onReachBottom() {
			if (this.total > this.list.length) {
				this.page++;
				this.evaluationList();
			}
		},
		methods: {
			searchFun(e) {
				this.value = e
				this.page = 1
				this.list = []
				this.evaluationList()
			},
			// getReward
			async evaluationList(){
				let {data,code} = await this.$u.api.shareUserList({pages:this.page, keys: this.value});
				if(code){
					if(this.page == 1 && !data.orders.data.lenght){
						this.status = 'nomore';
					}
					this.money = data.money
					this.list = [...this.list, ...data.orders.data];
					this.total = data.orders.total;
					if (this.total <= this.list.length) this.status = 'nomore';
					else this.status = 'loading';
				}
			 },
		}
	}
</script>

<style lang="scss" scoped >
.container{
	padding: 50rpx 32rpx;
	.noDate{
		width: 360rpx;
		position: absolute;
		left: 50%;
		top: 34%;
		transform: translate(-50%,-50%);
		color: #666666;
		font-size: 26rpx;
		text-align: center;
		image{
			width: 360rpx;
			height: 310rpx;
			display: block;
			margin-bottom: 78rpx;
		}
	}
	.list{
		padding: 38rpx 35rpx 0 35rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
		.head{
			display: flex;
			align-items: center;
			padding-bottom: 32rpx;
			border-bottom: 1rpx solid rgba(142,142,142,.24);
			image{
				width: 132rpx;
				height: 132rpx;
				flex: none;
				margin-right: 16rpx;
				border-radius: 6rpx;
			}
			.right{
				color: #999999;
				font-size: 24rpx;
				>view{
					margin-bottom: 18rpx;
					text{
						color: #333333;
					}
				}
			}
		}
		.bottom{
			color: #666666;
			font-size: 20rpx;
			display: flex;
			justify-content: flex-end;
			padding: 32rpx 0;
			align-items: center;
			text{
				color: #007664;
				font-size: 28rpx;
			}
		}
	}
}
.totalMoney{
	margin: 20rpx 0;
	width: 100%;
	text{
		display: inline-block;
		margin-top: 20rpx;
		color: #007664;
		width: 100%;
		text-align: right;
	}
}
</style>
<style >
page{
	background-color: #F6F7FA;
}
</style>
